package com.webmining.sherlock.util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class DataEncryptor {


    private static final int RADIX = 16;
    private static final int SIGNUM = 1;

    public static String encrypt(String password) {
        if (password == null)
            throw new IllegalArgumentException("Password must be not null.");
        try {
            MessageDigest digest = MessageDigest.getInstance("MD5");
            digest.update(password.getBytes(), 0, password.length());
            return new BigInteger(SIGNUM, digest.digest()).toString(RADIX);
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
    }
}
